package com.sondon.mayi.adapter;

import java.util.ArrayList;

import org.androidannotations.annotations.EBean;
import org.androidannotations.annotations.RootContext;

import com.sondon.mayi.entity.MyVoucher;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

/**
 * @Project : Fruit
 * @Package : com.sondon.mayi.adapter
 * @Class : MyVoucherAdapter
 * @Author : 蔡文锋
 * @DateTime：2015年6月29日 下午9:30:10
 * @Blog：http://blog.csdn.net/caiwenfeng_for_23
 * @Description : {  }
 *
 */
@EBean
public class MyVoucherListAdapter extends BaseAdapter {
	@RootContext
	Context context;
	ArrayList<MyVoucher> datas=new ArrayList<MyVoucher>();
	
	public void SetDatas(ArrayList<MyVoucher> datas){
		this.datas.clear();
		if(datas!=null && datas.size()>0){
			this.datas.addAll(datas);
		}
		notifyDataSetChanged();
	}
	
	public ArrayList<MyVoucher> GetDatas(){
		return this.datas;
	}
	
	@Override
	public int getCount() {

		return datas.size();
	}

	@Override
	public Object getItem(int position) {

		return null;
	}

	@Override
	public long getItemId(int position) {

		return position;
	}

	@Override
	public View getView(int position, View curtview, ViewGroup arg2) {
		MyVoucherList_Item item;
		if(curtview==null){
			item=MyVoucherList_Item_.build(context);
		}else{
			item=(MyVoucherList_Item) curtview;
		}
		item.bindData(datas.get(position),position);
		return item;
	}

}
